if (!window.waveserver) waveserver = {};
waveserver.ProtocolOpenRequest = function() { this.wavelet_id_prefix = [];  };

waveserver.ProtocolOpenRequest.prototype.has_maximum_wavelets = function() { return ( this.maximum_wavelets != null ); };

waveserver.ProtocolOpenRequest.prototype.serialize = function()
{
	var data = {};
	data["1"] = this.participant_id;
	data["2"] = this.wave_id;
	var arr_3 = [];
	for( var i = 0; i < this.wavelet_id_prefix.length; ++i )
	{
		arr_3.push( this.wavelet_id_prefix[i] );
	}
	data["3"] = arr_3;
	if ( this.has_maximum_wavelets() ) {
	data["4"] = this.maximum_wavelets;
	}
	return data;
};

waveserver.ProtocolOpenRequest.parse = function(data)
{
	if ( !data ) return null;
	var obj = new waveserver.ProtocolOpenRequest();
	obj.participant_id = data["1"];
	obj.wave_id = data["2"];
	obj.wavelet_id_prefix = data["3"];
	obj.maximum_wavelets = data["4"];
	if ( !obj.participant_id == null ) throw "Missing field participant_id";
	if ( !obj.wave_id == null ) throw "Missing field wave_id";
	return obj;
};

waveserver.ProtocolWaveletUpdate = function() { this.applied_delta = [];  };

waveserver.ProtocolWaveletUpdate.prototype.has_commit_notice = function() { return ( this.commit_notice != null ); };

waveserver.ProtocolWaveletUpdate.prototype.has_resulting_version = function() { return ( this.resulting_version != null ); };

waveserver.ProtocolWaveletUpdate.prototype.serialize = function()
{
	var data = {};
	data["1"] = this.wavelet_name;
	var arr_2 = [];
	for( var i = 0; i < this.applied_delta.length; ++i )
	{
		arr_2.push( this.applied_delta[i].serialize() );
	}
	data["2"] = arr_2;
	if ( this.has_commit_notice() ) {
	data["3"] = this.commit_notice.serialize();
	}
	if ( this.has_resulting_version() ) {
	data["4"] = this.resulting_version.serialize();
	}
	return data;
};

waveserver.ProtocolWaveletUpdate.parse = function(data)
{
	if ( !data ) return null;
	var obj = new waveserver.ProtocolWaveletUpdate();
	obj.wavelet_name = data["1"];
	var arr = [];
	var d = data["2"];
	for( var i = 0; i < d.length; ++i )
	{
		arr.push( protocol.ProtocolWaveletDelta.parse( d[i] ) );
	}
	obj.applied_delta = arr;
	obj.commit_notice = protocol.ProtocolHashedVersion.parse( data["3"] );
	obj.resulting_version = protocol.ProtocolHashedVersion.parse( data["4"] );
	if ( !obj.wavelet_name == null ) throw "Missing field wavelet_name";
	return obj;
};

waveserver.ProtocolSubmitRequest = function() {  };

waveserver.ProtocolSubmitRequest.prototype.serialize = function()
{
	var data = {};
	data["1"] = this.wavelet_name;
	data["2"] = this.delta.serialize();
	return data;
};

waveserver.ProtocolSubmitRequest.parse = function(data)
{
	if ( !data ) return null;
	var obj = new waveserver.ProtocolSubmitRequest();
	obj.wavelet_name = data["1"];
	obj.delta = protocol.ProtocolWaveletDelta.parse( data["2"] );
	if ( !obj.wavelet_name == null ) throw "Missing field wavelet_name";
	if ( !obj.delta == null ) throw "Missing field delta";
	return obj;
};

waveserver.ProtocolSubmitResponse = function() {  };

waveserver.ProtocolSubmitResponse.prototype.has_error_message = function() { return ( this.error_message != null ); };

waveserver.ProtocolSubmitResponse.prototype.has_hashed_version_after_application = function() { return ( this.hashed_version_after_application != null ); };

waveserver.ProtocolSubmitResponse.prototype.serialize = function()
{
	var data = {};
	data["1"] = this.operations_applied;
	if ( this.has_error_message() ) {
	data["2"] = this.error_message;
	}
	if ( this.has_hashed_version_after_application() ) {
	data["3"] = this.hashed_version_after_application.serialize();
	}
	return data;
};

waveserver.ProtocolSubmitResponse.parse = function(data)
{
	if ( !data ) return null;
	var obj = new waveserver.ProtocolSubmitResponse();
	obj.operations_applied = data["1"];
	obj.error_message = data["2"];
	obj.hashed_version_after_application = protocol.ProtocolHashedVersion.parse( data["3"] );
	if ( !obj.operations_applied == null ) throw "Missing field operations_applied";
	return obj;
};

